package matt.design;
import java.util.Date;

public class Item {
	
	private final long id;
	private String itemname, description;
	private String dueDate, startDate;
	private int priority;
	private Group itemGroup;
	private String recurring;
	private boolean completed;
	private String address;
	private String latitude;
	private String longitude;
	
	public Item(long id) {
		this.id = id;
	}
	
	public Item(long id, String itemname, String description, String dueDate,
			String startDate,short priority,Group itemGroup,String recurring, boolean completed, 
			String address, String latitude, String longitude) {
		this.id = id;
		this.itemname = itemname;
		this.description = description;
		this.dueDate = dueDate;
		this.startDate = startDate;
		this.priority = priority;
		this.itemGroup = itemGroup;
		this.recurring = recurring;
		this.completed = completed;
		this.address = address;
		this.latitude = latitude;
		this.longitude = longitude;
	}
	
	public int compareDate(Item item2){
		int comp;
		String date2 = item2.getDueDate();
		
		int year, month, day, year2, month2, day2;
		String[] s = dueDate.split("-");
		year = Integer.parseInt(s[2]);
		month = Integer.parseInt(s[0]);
		day = Integer.parseInt(s[1]);
		s = date2.split("-");
		year2 = Integer.parseInt(s[2]);
		month2 = Integer.parseInt(s[0]);
		day2 = Integer.parseInt(s[1]);
		if(year >= year2){
			if(year>year2){ //year is greater therefore after
				comp = 1;
			}
			else if(month >= month2){
				if(month > month2){ //year is = and month is greater, therefore after
					comp = 1;
				}
				else if(day >= day2){ //day is either greater or = so show it
					comp = 1;
				}
				else{
					comp = -1;
				}
			}
			else{
				comp = -1;
			}
		}
		else{
			comp = -1;
		}
		return comp;
	}
	
	public long getId() {
		return id;
	}
	
	public String getItemName() {
		return itemname;
	}
	
	public void setItemName(String itemname) {
		this.itemname = itemname;
	}
	
	public String getDueDate() {
		return dueDate;
	}
	
	public void setDueDate(String dueDate2) {
		this.dueDate = dueDate2;
	}
	
	public String getStartDate() {
		return startDate;
	}
	
	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}
	
	public int getPriority() {
		return priority;
	}
	
	public void setPriority(int priority) {
		this.priority = priority;
	}
	
	public Group getItemGroup() {
		return itemGroup;
	}
	
	public void setItemGroup(Group itemGroup) {
		this.itemGroup = itemGroup;
	}
	
	public String getRecurring() {
		return recurring;
	}
	
	public void setRecurring(String recurring) {
		this.recurring = recurring;
	}

	public String getDesc() {
		return description;
	}
	
	public void setDesc(String description) {
		this.description = description;
	}
	
	public boolean getCompleted() {
		return completed;
	}
	
	public void setCompleted(boolean val) {
		this.completed = val;
	}
	
	public String toString() {
		return itemname + " (" + dueDate + ")";
	}
	
	public String getAddress() {
		return this.address;
	}
	
	public void setAddress(String add) {
		this.address = add;
	}
	
	public String getLatitude() {
		return this.latitude;
	}
	public void setLatitude(String lat){
		this.latitude = lat;
	}
	
	public String getLongitude() {
		return this.longitude;
	}
	
	public void setLongitude(String longi) {
		this.longitude = longi;
	}
}
